package com.sys.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.sjjy.ta.iface.MonitoringService;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class GftContextListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {

    }

    /**
     * init context
     *
     * @author yipeng
     */
    public void contextInitialized(ServletContextEvent event) {
        ServletContext context = event.getServletContext();
        //LogInfoService service = (LogInfoService) WebApplicationContextUtils.getWebApplicationContext(context).getBean("LogInfoServiceImpl");


        final MonitoringService m = (MonitoringService) WebApplicationContextUtils.getWebApplicationContext(context).getBean("MonitoringImpl");


        Thread th = new Thread(new Runnable() {
            public void run() {
                while (true) {
                    m.startMonitorOnline();
                    try {
                        Thread.sleep(1000 * 30);
                    } catch (InterruptedException e) {

                    }
                }
            }
        });
        //th.start();


        /*PlanService service2 = (PlanService) WebApplicationContextUtils.getWebApplicationContext(context).getBean("PlanServiceImpl");
        service2.systemInit();*/

        /*try {
            context.setAttribute(Constants.SYS_LOGSETTINGS, service.initLogSettings());
            context.setAttribute(Constants.SYS_RIGHTSETTINGS, service.initRightSettings());
            //检查是否有用户,没有加入一条默认用户记录
            service.initUser();
        } catch (Exception e) {
            e.printStackTrace();
        }*/
	}
	
	

}
